package cn.tqfeiyang.springplus.framework.security;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public interface SecurityService {

    /**
     * 获取授权Token
     *
     * @return 授权Token
     */
    UsernamePasswordAuthenticationToken getAuthenticationToken();


    /**
     * 获取权限列表
     *
     * @return 权限列表
     */
    Collection<GrantedAuthority> getAuthorities();

    /**
     * 获取当前用户
     *
     * @return 用户信息
     */
    AuthenticationUserDetails getCurrentUser();

    /**
     * 获取用户Id
     *
     * @return 用户id
     */
    Long getUserId();

    /**
     * 是否拥有对应的权限
     *
     * @param anthority
     * @return boolean
     */
    boolean hasAuthority(String anthority);

    /**
     * 是否拥有列表中的任何一个权限
     *
     * @param authorities
     * @return boolean
     */
    boolean hasAnyAuthority(String... authorities);
}
